﻿
Partial Class Main
    Inherits System.Web.UI.MasterPage

    Public Shared _userid As Integer
    Public Shared Property UserID() As Integer
        Get
            Return _userid
        End Get
        Set(ByVal value As Integer)
            _userid = value
        End Set
    End Property

    Public Shared _videoid As Integer
    Public Shared Property videoID() As Integer
        Get
            Return _videoid
        End Get
        Set(ByVal value As Integer)
            _videoid = value
        End Set
    End Property


    Public Function NewMessages() As String
        Dim messages As Integer

        If HttpContext.Current.User IsNot Nothing Then
            If HttpContext.Current.User.Identity.IsAuthenticated Then
                If TypeOf HttpContext.Current.User.Identity Is FormsIdentity Then
                    Dim id As FormsIdentity = DirectCast(HttpContext.Current.User.Identity, FormsIdentity)
                    UserID = id.Name
                    Dim messageAdapter As New MainDbTableAdapters.MessagesTableAdapter()
                    messages = messageAdapter.NewMessages(UserID)

                    NewMessages = "[" & messages & "]"
                End If
            End If
        End If
        Return NewMessages
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Function getUserInfo() As String
        Dim userID As Integer
        If Request.Cookies("UserID") IsNot Nothing Then
            userID = Request.Cookies("UserID").Value
        End If

        getUserInfo = userID

    End Function

    Protected Sub lnkLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        FormsAuthentication.SignOut()
        FormsAuthentication.RedirectToLoginPage()
    End Sub
End Class

